package com.jiangnan.repository

import com.jiangnan.api.client.BookApiClient
import com.jiangnan.entity.Book
import com.jiangnan.entity.Res

class InteractionRepository {

    suspend fun markFavorite(userId: Int, bookId: Int) : Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.interactionApiService.markFavorite(userId, bookId)
        }
    }

    suspend fun updateRating(userId: Int, bookId: Int, rating: Double) : Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.interactionApiService.updateRating(userId, bookId, rating)
        }
    }


    suspend fun borrowBook(userId: Int, bookId: Int) : Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.interactionApiService.borrowBook(userId, bookId)
        }
    }

    suspend fun fetchFavoriteBooks(userId: Int): Res<List<Book>> {
        return BookApiClient.interactionApiService.getFavoriteBooks(userId)
    }

    suspend fun cancelFavorite(userId: Int, bookId: Int) : Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.interactionApiService.cancelFavorite(userId, bookId)
        }
    }

}